from enum import IntEnum, unique, Enum

from itpay.core.recharge_order.const import OrderCommentRank


@unique
class PayType(IntEnum):
    """
    支付分类
    """
    ALIPAY = 1  # 支付宝
    WECHAT = 2  # 微信
    HUABEI = 3  # 花呗
    CREDIT = 4  # 信用卡
    BANK_CARD = 5  # 银行卡


PayTypeCN = {
    PayType.ALIPAY.value: "支付宝",
    PayType.WECHAT.value: "微信",
    PayType.HUABEI.value: "花呗",
    PayType.CREDIT.value: "信用卡",
    PayType.BANK_CARD.value: "银行卡",
}


@unique
class PayMethodType(IntEnum):
    ALIPAY_PERSON_ACCOUNT = 1  # 支付宝个人账户支付
    ALIPAY_PERSON_ZKL = 2  # 支付宝个人吱口令支付
    ALIPAY_PERSON_ACCOUNT_QR_CODE = 3  # 支付宝个人账号二维码支付
    ALIPAY_PERSON_QR_CODE = 4  # 支付宝个人二维收款码支付
    ALIPAY_PERSON_BANK_CARD = 5  # 支付宝个人转银行卡
    ALIPAY_HUABEI = 6  # 支付宝花呗支付
    ALIPAY_CREDIT = 7  # 支付宝信用卡支付
    WECHAT_PERSON_QR_CODE = 8  # 微信个人二维收款码支付
    WECHAT_PERSON_BANK_CARD = 9  # 微信个人转银行卡
    WECHAT_CREDIT = 10  # 微信信用卡支付
    BANK_CARD = 11  # 直接银行卡支付:网银，银联，线下打款


PayRule = {
    PayType.ALIPAY: [PayMethodType.ALIPAY_PERSON_QR_CODE,
                     PayMethodType.ALIPAY_PERSON_ACCOUNT_QR_CODE,
                     PayMethodType.ALIPAY_PERSON_ZKL,
                     PayMethodType.ALIPAY_PERSON_ACCOUNT,
                     PayMethodType.ALIPAY_PERSON_BANK_CARD],
    PayType.WECHAT: [PayMethodType.WECHAT_PERSON_QR_CODE,
                     PayMethodType.WECHAT_PERSON_BANK_CARD],
    PayType.HUABEI: [PayMethodType.ALIPAY_HUABEI],
    PayType.CREDIT: [PayMethodType.ALIPAY_CREDIT,
                     PayMethodType.WECHAT_CREDIT],
    PayType.BANK_CARD: [PayMethodType.BANK_CARD]
}


@unique
class ReceiptType(IntEnum):
    ALIPAY = 1  # 支付宝
    WECHAT = 2  # 微信
    BANK_CARD = 3  # 银行卡


ReceiptTypeCN = {
    ReceiptType.ALIPAY.value: "支付宝",
    ReceiptType.WECHAT.value: "微信",
    ReceiptType.BANK_CARD.value: "银行卡",

}


@unique
class ReceiptMethodType(IntEnum):
    ALIPAY_PERSON = 1  # 支付宝个人收款
    ALIPAY_MCH = 2  # 支付宝商家收款
    WECHAT_PERSON = 3  # 微信个人收款
    WECHAT_MCH = 4  # 微信商家收款
    BANK_CARD = 5  # 银行卡收款


ReceiptRule = {
    ReceiptType.ALIPAY: [ReceiptMethodType.ALIPAY_PERSON, ReceiptMethodType.ALIPAY_MCH],
    ReceiptType.WECHAT: [ReceiptMethodType.WECHAT_PERSON, ReceiptMethodType.WECHAT_MCH],
    ReceiptType.BANK_CARD: [ReceiptMethodType.BANK_CARD]
}


@unique
class BankCode(Enum):
    ICBC = 'ICBC'  # 工商银行
    CCB = 'CCB'  # 建设银行
    BOC = 'BOC'  # 中国银行
    ABC = 'ABC'  # 农业银行
    BCM = 'BCM'  # 交通银行
    CMB = 'CMB'  # 招商银行
    PSBC = 'PSBC'  # 邮政银行
    CNCB = 'CNCB'  # 中信银行
    CEB = 'CEB'  # 光大银行
    HXB = 'HXB'  # 华夏银行
    SPDB = 'SPDB'  # 浦发银行
    CIB = 'CIB'  # 兴业银行
    CMBC = 'CMBC'  # 民生银行
    PAB = 'PAB'  # 平安银行
    CGB = 'CGB'  # 广发银行
    HRBB = 'HRBB'  # 哈尔滨银行
    CZB = 'CZB'  # 浙商银行
    QDCCB = 'QDCCB'  # 青岛银行
    CSCB = 'CSCB'  # 长沙银行
    NJCB = 'NJCB'  # 南京银行
    RCB = 'RCB'  # 农村商业银行
    OTHERS = 'OTHERS'  # 其它银行


@unique
class AgencyType(Enum):
    NORMAL_AGENCY = 1  # 子代理
    ADMIN_AGENCY = 2  # 总代


@unique
class AgencyOrderStatusType(Enum):
    CREATE = 1
    REFUSE = 2
    SUCCESS = 3
    CHASE = 4


AgencyOrderStatusCN = {AgencyOrderStatusType.CREATE.value: "待审核",
                       AgencyOrderStatusType.REFUSE.value: "拒绝",
                       AgencyOrderStatusType.SUCCESS.value: "成功",
                       AgencyOrderStatusType.CHASE.value: "已追分",
                       }


@unique
class AgencyTransactionType(Enum):
    # 命名规则 角色_收入(支出)_事件
    AGENCY_ADMIN_IN_RECHARGE = 1  # 总代充值
    AGENCY_ADMIN_OUT_RECHARGE = 2  # 代理充值，总代扣除相应的钱
    AGENCY_IN_RECHARGE = 3  # 代理充值
    AGENCY_OUT_USER_RECHARGE = 4  # 代理给玩家充值
    AGENCY_IN_CHASE = 5  # 代理追分
    AGENCY_IN_USER_RECHARGE_FAIL_RETURN = 6  # 用户充值失败返款给代理
    AGENCY_OUT_RECHARGE_CHASE = 7  # 子代被总代追分
    AGENCY_ADMIN_OUT_RECHARGE_CHASE = 8  # 总代被运营追分
    AGENCY_ADMIN_IN_RECHARGE_CHASE = 9  # 总代追子代分，自己加钱
    AGENCY_OUT_RECHARGE_NOTIFY_FAIL_CHASE = 10  # 通知商户上分，商户成功，却返回失败，手动追代理分


@unique
class ComplaintType(Enum):
    RECHARGE_UNSUCCESSFUL = 1  # 充值不到账
    BAD_ATTITUDE = 2  # 态度恶劣
    IGNORE_USER = 3  # 不理人
    OTHER = 4  # 其他
    AD_OTHER_GAME = 5  # 给其他游戏打广告
    INAPPROPRIATE_REMARKS = 6  # 不当言论


@unique
class AgencySortScoreType(Enum):
    WEEK_INIT = 1  # 每周初始化
    NEW_USER_RECHARGE_THIS_WEEK = 2  # 新增一个充值用户
    USER_RECHARGE = 3  # 用户充值
    USER_COMMENT = 4  # 用户评价
    USER_COMPLAIN = 5  # 用户投诉


ComplaintTypeCN = {
    ComplaintType.RECHARGE_UNSUCCESSFUL.value: "充值未到账",
    ComplaintType.BAD_ATTITUDE.value: "态度恶劣",
    ComplaintType.IGNORE_USER.value: "不理人",
    ComplaintType.OTHER.value: "其他",
    ComplaintType.AD_OTHER_GAME.value: "给其他游戏打广告",
    ComplaintType.INAPPROPRIATE_REMARKS.value: "不当言论"
}


@unique
class AgencyScoreEventType(Enum):
    ORDER_COMMENT = 1  # 订单评论
    ORDER_CHASE = 2  # 订单追分
    ORDER_RECHARGE = 3  # 用户充值


@unique
class AgencyReportType(Enum):
    DAY = 1  # 当天数据
    MONTH = 2  # 当月


DAILY_SCORE_LIMIT = {
    "upper_limit": 15,
    "lower_limit": -5
}

ORDER_COMMENT_SCORE_CONF = {
    OrderCommentRank.BAD: -1,
    OrderCommentRank.NORMAL: 0,
    OrderCommentRank.GOOD: 1,

}

# (金额档位线单位分，分数) 例如 50000元对应5分
ORDER_AMOUNT_SCORE_CONF = [
    (5000000, 5),
    (500000, 3),
    (50000, 2),
    (0, 1),
]

# 代理分数对应等级
AGENCY_SCORE_LEVEL = [
    (1000, 3),
    (200, 2),
]

# 默认开场白
DEFAULT_PROLOGUE = '亲，您好，下方按钮是目前可用充值方式，请点选您需要的充值方式'

# 默认头像
DEFAULT_AVATAR = '1558000605371.jpg'

QUICK_REPLY_COUNT_LIMIT = 5

AGENCY_BALANCE_WARNING = 200000

COMPLAIN_HANDLER_MSG = """
<div class="operation-info" data-title="{{投诉处理通知}}">
        <p class="operation-info-title">投诉处理通知</p>
        <p class="operation-info-item"><span class="operation-info-subtitle">投诉时间：</span><span
                class="operation-info-subinfo">{created_at}</span></p>
        <p class="operation-info-item"><span class="operation-info-subtitle">投诉对象：</span><span
                class="operation-info-subinfo">{agency_name}</span></p>
        <p class="operation-info-item"><span class="operation-info-subtitle">投诉原因：</span><span
                class="operation-info-subinfo">{complain_type}</span></p>
        <p class="operation-info-item"><span class="operation-info-subtitle">投诉内容：</span><span
                class="operation-info-subinfo">{complain_content}</span></p>
        <p class="operation-info-item"><span class="operation-info-subtitle">处理结果：</span><span
                class="operation-info-subinfo">{remark}</span></p>
    </div>
"""

COMPLAIN_REQUIRE_MSG = """
<div class="operation-info" data-title="{{投诉受理通知}}">
        <p class="operation-info-title">投诉受理通知</p>
        <p class="operation-info-item"><span class="operation-info-subtitle">投诉对象：</span><span
                class="operation-info-subinfo">{agency_name}</span></p>
        <p class="operation-info-item"><span class="operation-info-subtitle">投诉原因：</span><span
                class="operation-info-subinfo">{complain_type}</span></p>
        <p class="operation-info-item"><span class="operation-info-subtitle">投诉内容：</span><span
                class="operation-info-subinfo">{complain_content}</span></p>
</div>
"""


BALANCE_WARNING_MSG = """
<div class="operation-info" data-title="{余额不足提醒}">
        <p class="operation-info-title">余额不足提醒</p>
        <p style="font-size: 16px;color: #222">你当前的可用余额不足2000，系统已自动撤下您的代理展示位，请您及时充值。</p>
</div>
"""


RECEIPT_ADDRESS_LIMIT_MSG = """
<div class="operation-info" data-title="{{收款账号限额提醒}}">
        <p class="operation-info-title">收款账号限额提醒</p>
        <p style="font-size: 16px;color: #222">您的收款账号 {receipt_id} 已满限额，系统已自动停用该账号，将在明日自动恢复开启，请您及时调整您的收款资源。</p>
</div>
"""
